package com.imooc.freecoding.mapper;

import com.imooc.freecoding.entity.News;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Repository;

@Mapper
@Repository
public interface NewsMapper {
    // 根据id查询news
    @Select("SELECT * FROM news WHERE id = #{id}")
    public News selectById(Long id);

    @Insert("INSERT INTO news(title,author,source,content) VALUES(#{title},#{author},#{source},#{content})")
    public void insertNews(News news);

    @Delete("DELETE FROM news WHERE id = #{id}")
    public void deleteNews(Long id);

    @Update("UPDATE news SET title=#{title},author=#{author},source=#{source},content=#{content} WHERE id=#{id}")
    public void updateNews(News news);
}
